package com.hst.capacity.facade.rest;

import cn.hutool.core.util.StrUtil;
import com.hst.capacity.application.biz.SpecialOrderBiz;
import com.hst.capacity.domain.exception.BusinessException;
import com.hst.capacity.domain.model.request.dispatch.DispatchDriverParam;
import com.hst.capacity.domain.model.request.specialcar.SpListParam;
import com.hst.capacity.domain.model.response.DefaultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

import static com.hst.capacity.domain.model.response.DefaultVO.success;

/**
 *  城际订单录入模块Controller，城际订单 CRUD，检索等。
 *
 * */
@RequestMapping("/order/airport")
@RestController
public class AirportOrderController {

    @Autowired
    private SpecialOrderBiz specialOrderBiz;

    /**
     * 订单检索查询
     * @param param
     * @return
     */
    @PostMapping("/search")
    private DefaultVO spOrderSearch(@RequestBody @Valid SpListParam param){
        return success(specialOrderBiz.spOrderSearch(param));
    }

    /**
     * 获取指定城市今日录单信息
     * @param param
     * @return
     */
    @PostMapping("/list/region/today")
    private DefaultVO getNewOrderListByRegionCode(@RequestBody @Valid SpListParam param){
        return success(specialOrderBiz.getNewOrderListByRegionCode(param));
    }

    /**
     * 订单详情
     * @param param
     * @return
     */
    @PostMapping("/detail")
    private DefaultVO spOrderDetail(@RequestBody @Valid Map<String,String> param){
        String idOrder = param.get("idOrder");
        if (StrUtil.isEmpty(idOrder))
            throw new BusinessException(4001,"订单号[idOrder]不能为空");
        return success(specialOrderBiz.spOrderDetail(idOrder));
    }

    /**
     * 更换订单派遣司机
     * @param param
     * @return
     */
    @PostMapping("/redispatch/driver")
    private DefaultVO reDispatchDriver(@RequestBody @Valid DispatchDriverParam param){
        return success(specialOrderBiz.reDispatchDriver(param));
    }

//    /**
//     * 订单销毁
//     * @param param
//     * @return
//     */
//    @PostMapping("/destroy")
//    private DefaultVO spOrderDestroy(@RequestBody @Valid SpOrderDestroyParam param){
//        return success(specialOrderBiz.spOrderDestroy(param));
//    }
//    /**
//     * 修改备注
//     * @param param
//     * @return
//     */
//    @PostMapping("/re/memo")
//    private DefaultVO spReMemo(@RequestBody Map<String,String> param){
//        String idOrder= param.get("idOrder");
//        String memo=param.get("memo");
//        if (StrUtil.isEmpty(idOrder))
//            throw new BusinessException(4001,"订单号[idOrder]不能为空");
//        return success(specialOrderBiz.spReMemo(idOrder,memo));
//    }
//
//    /**
//     * 订单支付信息
//     * @param param
//     * @return
//     */
//    @PostMapping("/billInfo")
//    private DefaultVO orderBillInfo(@RequestBody Map<String,String> param){
//        String idOrder = param.get("idOrder");
//        if (StrUtil.isEmpty(idOrder))
//            throw new BusinessException(4001,"订单号[idOrder]不能为空");
//        return success(specialOrderBiz.getOrderBillInfo(idOrder));
//    }

}
